home *** CD-ROM | disk | FTP | other *** search
- Path: csus.edu!news
- From: wleong@sfsu.edu (Jerry Leong)
- Newsgroups: comp.lang.c
- Subject: Possible to use #define to define global variable?
- Date: Mon, 26 Feb 1996 02:39:09 GMT
- Organization: San Francisco State University
- Message-ID: <31311b97.1170723@news.csus.edu>
- NNTP-Posting-Host: wleong@pluto.sfsu.edu
- X-Newsreader: Forte Agent .99d/32.182
-
- Hi,
- I recently need to do programming that restrict the number of
- bytes in a structure. Knowing that it might not possible to turn off
- padding in the structure, I am now thinking if it is possible to use
- #define to define a global variable? That way, I can fix the size
- of my structure without worrying about the padding.
-
- Here's what I have in mind :
-
- Normally,
- struct MSG{
- char buffer[3];
- };
- sizeof(struct MSG) is 4 due the the padding on the structure.
-
- What if,
- #define buffer char[3];
- That might work, but than I couldn't assign anything to buffer due
- to the nature of #define.
-
- Is there anyway to work around this problem?
-
- p/s: I am currently working on UNIX for this program. Thanx in advance
-
- for your responce.
-